﻿using System;
using System.Text;
#if !PocketPC
    using System.Runtime.Serialization;
#endif 

namespace GeoFramework.Licensing
{
#if !PocketPC
    [Serializable]
#endif
	/// <summary>Represents information about a license-related problem.</summary>
	/// <remarks>
	/// 	<para>This exception class is used whenever a license cannot be granted for any
	///     reason. License exceptions typically occur in the following situations:</para>
	/// 	<list type="bullet">
	/// 		<item>
	/// 			<ul class="noindent">
	/// 				<li>A beta period is in effect but the beta period has expired.</li>
	/// 				<li>A trial period is in effect but the trial period has expired.</li>
	/// 				<li>An invalid license key has been specified.</li>
	/// 				<li>An attempt to tamper with the license key has been detected.</li>
	/// 				<li>An attempt to tamper with the licensing system via Reflection has
	///                 been detected.</li>
	/// 			</ul>
	/// 		</item>
	/// 	</list>
	/// </remarks>
    public sealed class LicenseException : SystemException
    {
        private Type pType = null;

        public LicenseException(Type type)
			: base("A license could not be granted for the requested Type.  Please see Inner Exception property for more detailed information.")
        {
            pType = type;
        }

        public LicenseException(Type type, string message) 
			: base(message)
        {
            pType = type;
        }

        public LicenseException(Type type, string message, Exception innerException) 
			: base(message, innerException)
        {
            pType = type;
        }

        public LicenseException(Type type, object instance, string message) 
			: base(message)
        {
            pType = type;
        }

        public LicenseException(Type type, object instance, string message, Exception innerException) 
			: base(message, innerException)
        {
            pType = type;
        }


#if !PocketPC
        public LicenseException(SerializationInfo info, StreamingContext context) : base(info, context)
        { }
#endif

		/// <summary>Indicates the type of object for which a license could not be granted.</summary>
		/// <value>A <strong>Type</strong> describing the object which failed validation.</value>
        public Type LicensedType
        {
            get
            {
                return pType;
            }
        }
    }
}
